const Cache = require('../utils/cache')

/** 权限校验中间件 */
const permissionCheck = (req,res,next)=>{
    let token = req.header('x-token')
    let loginuser = Cache.get(token)
    if(loginuser.is_admin == 0) {
    	res.send({
    		'code': 100004,
    		'msg': '非管理员无权执行该操作'
    	})
    	return;
    }
    next()
}

module.exports = permissionCheck